package guava;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class GuavaThreadPoolFactory {

    private GuavaThreadPoolFactory() {
    }

    private static class ThreadPoolHolder {
        private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(3, 5,
                1, TimeUnit.SECONDS, new LinkedBlockingQueue<>(32), new ThreadFactoryBuilder().setNameFormat("guava-pool-%d").build());
    }

    public static ExecutorService getThreadPool() {
        return ThreadPoolHolder.THREAD_POOL;
    }

}
